n = int(input())
m = int(input())
l = list(map(int, input().split()))
s = []
cur = []
for x in l:
    if len(cur) < 2:
        cur.append(x)
    else:
        s.append(cur)
        cur = []
dp = [0]*n
visited = [0]*n

def dfs(i):
    for x in s:
        if visited[x[1]] != 1:
            dp[x[1]] += 1
            dfs(x[0])

for x in s:
    visited = [0] * n
    dp[x[1]] += 1
    visited[x[0]]=1
    dfs(x[0])
res = dp.count(n-1)

